package com.kaka.bus.adapter;

import android.support.annotation.Nullable;
import android.view.ViewGroup;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.kaka.bus.R;
import com.kaka.bus.bean.CardBean;
import com.kaka.bus.view.DensityUtil;

import java.util.List;

public class CardListAdapter extends BaseQuickAdapter<CardBean, BaseViewHolder> {
    public CardListAdapter(int layoutResId, @Nullable List<CardBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, CardBean item) {
        if (helper.getAdapterPosition() == mData.size() - 1) {
            ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) helper.itemView.getLayoutParams();
            layoutParams.bottomMargin = DensityUtil.dp2px(20);
            helper.itemView.setLayoutParams(layoutParams);
        } else {
            ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) helper.itemView.getLayoutParams();
            layoutParams.bottomMargin = 0;
            helper.itemView.setLayoutParams(layoutParams);
        }
        helper.setText(R.id.tv_cardmoney, "￥" + item.getAmount());
        helper.addOnClickListener(R.id.tv_carddtail);
    }
}
